<style type="text/css">
    .bjui-pageHeader{
        font-size: 18px;
        font-weight: bold;
    }
    .form{
        padding: 15px;
    }
    .form dl {
        overflow: hidden;
        padding-top: 15px;
    }

    .form dt {
        color: #666;
        float: left;
        font-size: 14px;
        padding: 3px 0 0;
        width: 11%;
    }
    .form dd {
        float: left;
        line-height: 22px;
    }
    dd.desc {
        height: 30px;
        padding: 0 10px;
        width: 150px;
    }
</style>
<script type="text/javascript">
    $(function(){
        var rid = <if condition="$role['id'] gt 0">{$role.id}<else/>0</if>;
        var validate={name:1,code:1};
        $("input[name='ruleTitle']").focus();//聚焦
        //验证用户名
        $("input[name='ruleName']").blur(function(){
            var name = $("input[name='ruleName']");
            var condition=$("input[name='condition']");
            if($.trim(name.val())==''){
                validate.name = 1;
                name.parent().find("span").remove().end().append("<span class='error'>规则标识不能为空</span>");
                return ;
            }
            $.post("{:U('Auth/checkAuthName')}",{name:$.trim(name.val()),condition:$.trim(condition.val()), id:rid},function(stat){
                if(stat==1){    
                    validate.name = 1;          
                    name.parent().find("span").remove().end().append("<span class='error'>规则标识已经存在</span>");
                }else{                  
                    validate.name = 0;  
                    name.parent().find("span").remove();
                }
        
            })          
        });

        $("#form_do").submit(function(){
            if(validate.name==0){
                return true;
            }
            //验证用户组名
            $("input[name='name']").trigger("blur");
            return false;
        });
    });
</script>
<div class="bjui-pageHeader">
    <div class="glyphicon glyphicon-th-large">添加权限</div>
</div>
<div class="bjui-pageContent">
    <div class="form">
        <form method='post'  data-toggle="validate" action="{:U('Auth/addHandle')}">
            <dl>
                <dt>规则简述：</dt>
                <dd>
                    <input type="text" name="ruleTitle"  class="input-nm" size="30" value=""/>
                </dd>
            </dl>
            <dl>
                <dt>规则标识：</dt>
                <dd>
                    <input type="text" name="ruleName"  class="input-nm" size="30" value=""/>
                </dd>
            </dl>
            <dl>
                <dt>附加条件：</dt>
                <dd>
                    <input type="text" name="condition"  class="input-nm" size="30" value=""/>
                </dd>
            </dl>
            <dl>
                <dt>开启：</dt>
                <dd>
                    <input type="radio" name="status" value="1" checked="checked"   />
                    开启
                    <input type="radio" name="status" value="0">关闭</dd>
            </dl>
            <dl>
                <dt>所属分组：</dt>
                <dd>
                    <select name="mid" data-toggle="selectpicker" data-width="200">
                        <volist name="modules" id="vo">
                            <option value="{$vo['id']}">{$vo['moduleName']}</option>
                        </volist>
                    </select>
                </dd>
            </dl>
        </form>
    </div>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">关闭</button>
        </li>
        <li>
            <button data-icon="save" class="btn btn-default" type="submit">保存</button>
        </li>
    </ul>
</div>